<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CustomUserControl="clr-namespace:GBlason.Control.CustomUserControl">
    
    <Style TargetType="{x:Type Button}" x:Key="MenuRecentFileButtonStyle">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border
                        x:Name="Border"
                        BorderThickness="1"
                        BorderBrush="Transparent"
                        CornerRadius="3">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="0.5*"/>
                                <RowDefinition Height="0.5*"/>
                            </Grid.RowDefinitions>
                            <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" Grid.RowSpan="2" CornerRadius="3,3,3,3" Name="glow" Opacity="0" Background="{StaticResource GlowBrush}">
                            </Border>
                            <Border HorizontalAlignment="Stretch" Margin="0" CornerRadius="3,3,4,4" Name="glossy" Opacity="0" Background="{StaticResource GlossyBrush}">
                            </Border>
                            <Border HorizontalAlignment="Stretch" Margin="0" CornerRadius="3" Name="innerLight" Opacity="0" Background="#44FFFFFF" BorderBrush="White" BorderThickness="1"
                                    Grid.RowSpan="2">
                            </Border>

                            <ContentPresenter Name="content"
                                              Margin="0"
                                              Grid.RowSpan="2"
                                              RecognizesAccessKey="True"
                                              VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--<Trigger Property="IsKeyboardFocused" Value="true">
                            <Setter TargetName="glow" Property="Opacity" Value="1"/> 
                            <Setter TargetName="glossy" Property="Opacity" Value="1"/>
                            <Setter TargetName="innerLight" Property="Opacity" Value="1"/>
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource ResourceKey=YellowBackgroundBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="#FFCDA223" />
                        </Trigger>-->
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="glow" Property="Opacity" Value="1"/>
                            <Setter TargetName="glossy" Property="Opacity" Value="1"/>
                            <Setter TargetName="innerLight" Property="Opacity" Value=".4"/>
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource ResourceKey=YellowBackgroundBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="#FFCDA223" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource ResourceKey=DarkYellowBackgroundBrush}" />
                            <Setter TargetName="innerLight" Property="Opacity" Value="1"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="#FFF3AD09" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="glow" Property="Opacity" Value="0"/>
                            <Setter TargetName="glossy" Property="Opacity" Value="0"/>
                            <!--<Setter TargetName="Border" Property="Background" Value="{StaticResource CustomNormalButtonDisabledBackgroundBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource FontDisabledBackgroundBrush}" />-->
                            <Setter TargetName="content" Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- CommandComboBox -->

    <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="20" />
            </Grid.ColumnDefinitions>
            <Border x:Name="ExternBorder" 
                            Grid.ColumnSpan="2"
                            CornerRadius="0"
                            Background="{DynamicResource ResourceKey=NeutralBackgroundBrush}"
                            BorderBrush="#BB888888"
                            BorderThickness="1" />
            <Border Grid.Column="0"
                        x:Name="LeftBorder"
                            CornerRadius="0"
                            Margin="1,1,0,1" 
                            Background="#00FFFFFF" 
                            BorderBrush="#00888888"
                            BorderThickness="0,0,1,0" />
            <Border Grid.Column="1"
                        x:Name="RightBorder"
                        Margin="0,1,1,1"
                            CornerRadius="0"
                            Background="#00FFFFFF">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="0.5*"/>
                        <RowDefinition Height="0.5*"/>
                    </Grid.RowDefinitions>
                    <Border x:Name="Glossy" Grid.Row="0"
                                Margin="0"
                                Background="{DynamicResource ResourceKey=GlossyBrush}"
                                Opacity="0"/>
                    <Border x:Name="Glow" Grid.Row="1"
                                Margin="1"
                                Background="{DynamicResource ResourceKey=GlowBrush}"
                                Opacity="0"/>
                </Grid>
            </Border>
            <Path x:Name="Arrow"
                          Grid.Column="1"     
                          Fill="Black"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          Data="M 0 0 L 4 4 L 8 0 Z"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="ToggleButton.IsMouseOver" Value="true">
                <Setter TargetName="RightBorder" Property="Background" Value="{StaticResource ResourceKey=YellowBackgroundBrush}" />
                <Setter TargetName="ExternBorder" Property="BorderBrush" Value="#FFCDA223"/>
                <Setter TargetName="LeftBorder" Property="BorderBrush" Value="#FFCDA223"/>
                <Setter TargetName="Glossy" Property="Opacity" Value="1"/>
                <Setter TargetName="Glow" Property="Opacity" Value="1"/>
            </Trigger>
            <Trigger Property="ToggleButton.IsChecked" Value="true">
                <Setter TargetName="RightBorder" Property="Background" Value="{StaticResource ResourceKey=DarkYellowBackgroundBrush}" />
                <Setter TargetName="ExternBorder" Property="BorderBrush" Value="#FFF3AD09"/>
                <Setter TargetName="LeftBorder" Property="BorderBrush" Value="#FFF3AD09"/>
                <Setter TargetName="Glossy" Property="Opacity" Value="1"/>
                <Setter TargetName="Glow" Property="Opacity" Value="1"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="RightBorder" Property="Background" Value="#33AAAAAA" />
                <Setter TargetName="LeftBorder" Property="Background" Value="#33AAAAAA" />
                <Setter TargetName="LeftBorder" Property="BorderBrush" Value="#33AAAAAA" />
                <Setter TargetName="ExternBorder" Property="BorderBrush" Value="#99999999" />
                <Setter Property="Foreground" Value="#99999999"/>
                <Setter TargetName="Arrow" Property="Fill" Value="#99999999" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox">
        <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" />
    </ControlTemplate>

    <Style x:Key="{x:Type CustomUserControl:CommandComboBox}" TargetType="{x:Type CustomUserControl:CommandComboBox}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="MinWidth" Value="120"/>
        <Setter Property="MinHeight" Value="20"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CustomUserControl:CommandComboBox}">
                    <Grid>
                        <ToggleButton Name="ToggleButton"
                                          Template="{StaticResource ComboBoxToggleButton}" 
                                          Grid.Column="2" 
                                          Focusable="false"
                                          IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                          ClickMode="Press">
                        </ToggleButton>
                        <ContentPresenter Name="ContentSite"
                                              IsHitTestVisible="False" 
                                              Content="{TemplateBinding SelectionBoxItem}"
                                              ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                              ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                              Margin="3,3,23,3"
                                              VerticalAlignment="Center"
                                              HorizontalAlignment="Left" />
                        <TextBox x:Name="PART_EditableTextBox"
                                     Style="{x:Null}" 
                                     Template="{StaticResource ComboBoxTextBox}" 
                                     HorizontalAlignment="Left" 
                                     VerticalAlignment="Center" 
                                     Margin="3,3,23,3"
                                     Focusable="True" 
                                     Background="Transparent"
                                     Visibility="Hidden"
                                     IsReadOnly="{TemplateBinding IsReadOnly}"/>
                        <Popup Name="Popup"
                                   Placement="Bottom"
                                   IsOpen="{TemplateBinding IsDropDownOpen}"
                                   AllowsTransparency="True" 
                                   Focusable="False"
                                   PopupAnimation="Slide">
                            <Grid Name="DropDown"
                                      SnapsToDevicePixels="True"                
                                      MinWidth="{TemplateBinding ActualWidth}"
                                      MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                <Border x:Name="DropDownBorder"
                                            Background="#FFFFFFFF"
                                            BorderThickness="1"
                                            Margin="0,2,0,0"
                                            BorderBrush="#BB333333"/>
                                <ScrollViewer Margin="1,4,1,1" SnapsToDevicePixels="True">
                                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="false">
                            <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="#99999999"/>
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                        </Trigger>
                        <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
                            <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="0"/>
                        </Trigger>
                        <Trigger Property="IsEditable" Value="true">
                            <Setter Property="IsTabStop" Value="false"/>
                            <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Type ComboBoxItem}" TargetType="{x:Type ComboBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                    <Border x:Name="Border"
                                Margin="1,0,1,1"
                                SnapsToDevicePixels="true"
                                BorderThickness="1"
                                BorderBrush="Transparent"
                                Background="Transparent">
                        <Grid ClipToBounds="True"
                                  x:Name="gridIntern"
                                  Margin="-1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="0.5*"/>
                                <RowDefinition Height="0.5*"/>
                            </Grid.RowDefinitions>
                            <Border x:Name="Glossy" Grid.Row="0"
                                        Margin="1,1,1,0"
                                        Background="{StaticResource ResourceKey=GlossyBrush}"
                                        Opacity="0"/>
                            <Border x:Name="Glow" Grid.Row="1"
                                        Margin="1,0,1,1"
                                        Background="{StaticResource ResourceKey=GlowBrush}"
                                        Opacity="0"/>
                            <ContentPresenter x:Name="Content" Grid.RowSpan="2"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="#AAAAAAAA"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="#AA888888"/>
                            <Setter TargetName="Glossy" Property="Opacity" Value="1"/>
                            <Setter TargetName="Glow" Property="Opacity" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="gridIntern" Property="Background" Value="{StaticResource ResourceKey=YellowBackgroundBrush}"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="#BB333333"/>
                            <Setter TargetName="Glossy" Property="Opacity" Value="1"/>
                            <Setter TargetName="Glow" Property="Opacity" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Content" Property="Opacity" Value=".55"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- GridSplitter -->

    <Style TargetType="GridSplitter" x:Key="GridSplitterStyle">
        <Setter Property="Background" Value="{StaticResource GlobalBackgroundBrush}" />
        <Setter Property="IsTabStop" Value="true" />
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="PreviewStyle">
            <Setter.Value>
                <Style TargetType="Control">
                    <Setter Property="Background" Value="{StaticResource GlobalBackgroundBrush}" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Control">
                                <Grid x:Name="Root" Opacity=".5">

                                    <!-- Background -->
                                    <Rectangle Fill="{TemplateBinding Background}" />

                                    <!-- Horizontal Template -->
                                    <Grid x:Name="HorizontalTemplate" Height="6">
                                        <!-- Just show the faint gray grid splitter rectangle with no other details -->
                                    </Grid>

                                    <!-- Vertical Template -->
                                    <Grid x:Name="VerticalTemplate" Visibility="Collapsed" Width="6">
                                        <!-- Just show the faint gray grid splitter rectangle with no other details -->
                                    </Grid>

                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="GridSplitter">
                    <Grid x:Name="Root" IsHitTestVisible="{TemplateBinding IsEnabled}">

                        <!-- VSM -->
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <!-- Background -->
                        <Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0" />

                        <!-- Horizontal Template -->
                        <Grid x:Name="HorizontalTemplate" Height="10">
                            <StackPanel Height="6" VerticalAlignment="Center">
                                <Rectangle Height="1" Margin="1" Width="10" StrokeThickness="0" Fill="#FF868686" />
                                <Rectangle Height="1" Margin="1" Width="10" StrokeThickness="0" Fill="#FF868686" />
                            </StackPanel>
                        </Grid>

                        <!-- Vertical Template -->
                        <Grid x:Name="VerticalTemplate" Visibility="Collapsed" Width="10">
                            <StackPanel Width="6" VerticalAlignment="Center" Orientation="Horizontal">
                                <Rectangle Width="1" Margin="1" Height="10" StrokeThickness="0" Fill="#FF868686" />
                                <Rectangle Width="1" Margin="1" Height="10" StrokeThickness="0" Fill="#FF868686" />
                            </StackPanel>
                        </Grid>

                        <!-- Focus Visual -->
                        <Rectangle x:Name="FocusVisual" Stroke="#FF6DBDD1" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
